#include <iostream>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    vector<int> a(n);
    long long total = 0;
    int odd_cnt = 0;

    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        total += a[i];
        if (a[i] % 2 != 0)
        {
            odd_cnt++;
        }
    }

    while (q--)
    {
        int op, x;
        cin >> op >> x;

        if (op == 1)
        {
            // 对奇数堆添加x
            total += (long long)odd_cnt * x;
            // 如果x是奇数，所有奇数堆会变成偶数堆
            if (x % 2 == 1)
            {
                odd_cnt = 0;
            }
        }
        else
        {
            // 对偶数堆添加x
            int even_cnt = n - odd_cnt;
            total += (long long)even_cnt * x;
            // 如果x是奇数，所有偶数堆会变成奇数堆
            if (x % 2 == 1)
            {
                odd_cnt = n;
            }
        }
    }

    cout << total << endl;
    return 0;
}
